﻿<template>
  <a-modal
    :title="title"
    width="40%"
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleSubmit"
    @cancel="()=>{this.visible=false}"
  >
    <a-spin :spinning="loading">
      <a-form-model ref="form" :model="entity" :rules="rules" v-bind="layout">
        <a-form-model-item label="更新时间" prop="UpdateTime">
          <a-input v-model="entity.UpdateTime" autocomplete="off" placeholder="更新时间" />
        </a-form-model-item>
        <a-form-model-item label="客户编码" prop="cCusCode">
          <a-input v-model="entity.cCusCode" autocomplete="off" placeholder="客户编码" />
        </a-form-model-item>
        <a-form-model-item label="客户名称" prop="cCusName">
          <a-input v-model="entity.cCusName" autocomplete="off" placeholder="客户名称" />
        </a-form-model-item>
        <a-form-model-item label="客户简称" prop="cCusAbbName">
          <a-input v-model="entity.cCusAbbName" autocomplete="off" placeholder="客户简称" />
        </a-form-model-item>
        <a-form-model-item label="客户分类编码" prop="cCCCode">
          <a-input v-model="entity.cCCCode" autocomplete="off" placeholder="客户分类编码" />
        </a-form-model-item>
        <a-form-model-item label="地区编码" prop="cDCCode">
          <a-input v-model="entity.cDCCode" autocomplete="off" placeholder="地区编码" />
        </a-form-model-item>
        <a-form-model-item label="所属行业" prop="cTrade">
          <a-input v-model="entity.cTrade" autocomplete="off" placeholder="所属行业" />
        </a-form-model-item>
        <a-form-model-item label="地址" prop="cCusAddress">
          <a-input v-model="entity.cCusAddress" autocomplete="off" placeholder="地址" />
        </a-form-model-item>
        <a-form-model-item label="邮政编码" prop="cCusPostCode">
          <a-input v-model="entity.cCusPostCode" autocomplete="off" placeholder="邮政编码" />
        </a-form-model-item>
        <a-form-model-item label="纳税人登记号" prop="cCusRegCode">
          <a-input v-model="entity.cCusRegCode" autocomplete="off" placeholder="纳税人登记号" />
        </a-form-model-item>
        <a-form-model-item label="开户银行" prop="cCusBank">
          <a-input v-model="entity.cCusBank" autocomplete="off" placeholder="开户银行" />
        </a-form-model-item>
        <a-form-model-item label="银行账号" prop="cCusAccount">
          <a-input v-model="entity.cCusAccount" autocomplete="off" placeholder="银行账号" />
        </a-form-model-item>
        <a-form-model-item label="法人" prop="cCusLPerson">
          <a-input v-model="entity.cCusLPerson" autocomplete="off" placeholder="法人" />
        </a-form-model-item>
        <a-form-model-item label="Email地址" prop="cCusEmail">
          <a-input v-model="entity.cCusEmail" autocomplete="off" placeholder="Email地址" />
        </a-form-model-item>
        <a-form-model-item label="联系人" prop="cCusPerson">
          <a-input v-model="entity.cCusPerson" autocomplete="off" placeholder="联系人" />
        </a-form-model-item>
        <a-form-model-item label="电话" prop="cCusPhone">
          <a-input v-model="entity.cCusPhone" autocomplete="off" placeholder="电话" />
        </a-form-model-item>
        <a-form-model-item label="传真" prop="cCusFax">
          <a-input v-model="entity.cCusFax" autocomplete="off" placeholder="传真" />
        </a-form-model-item>
        <a-form-model-item label="手机" prop="cCusHand">
          <a-input v-model="entity.cCusHand" autocomplete="off" placeholder="手机" />
        </a-form-model-item>
        <a-form-model-item label="扣率" prop="iCusDisRate">
          <a-input v-model="entity.iCusDisRate" autocomplete="off" placeholder="扣率" />
        </a-form-model-item>
        <a-form-model-item label="信用等级" prop="cCusCreGrade">
          <a-input v-model="entity.cCusCreGrade" autocomplete="off" placeholder="信用等级" />
        </a-form-model-item>
        <a-form-model-item label="信用额度" prop="iCusCreLine">
          <a-input v-model="entity.iCusCreLine" autocomplete="off" placeholder="信用额度" />
        </a-form-model-item>
        <a-form-model-item label="信用期限" prop="iCusCreDate">
          <a-input v-model="entity.iCusCreDate" autocomplete="off" placeholder="信用期限" />
        </a-form-model-item>
        <a-form-model-item label="付款条件编码" prop="cCusPayCond">
          <a-input v-model="entity.cCusPayCond" autocomplete="off" placeholder="付款条件编码" />
        </a-form-model-item>
        <a-form-model-item label="发货地址" prop="cCusOAddress">
          <a-input v-model="entity.cCusOAddress" autocomplete="off" placeholder="发货地址" />
        </a-form-model-item>
        <a-form-model-item label="发运方式编码" prop="cCusOType">
          <a-input v-model="entity.cCusOType" autocomplete="off" placeholder="发运方式编码" />
        </a-form-model-item>
        <a-form-model-item label="客户总公司编码" prop="cCusHeadCode">
          <a-input v-model="entity.cCusHeadCode" autocomplete="off" placeholder="客户总公司编码" />
        </a-form-model-item>
        <a-form-model-item label="应收余额" prop="iARMoney">
          <a-input v-model="entity.iARMoney" autocomplete="off" placeholder="应收余额" />
        </a-form-model-item>
        <a-form-model-item label="最后交易日期" prop="dLastDate">
          <a-input v-model="entity.dLastDate" autocomplete="off" placeholder="最后交易日期" />
        </a-form-model-item>
        <a-form-model-item label="停用日期" prop="dEndDate">
          <a-input v-model="entity.dEndDate" autocomplete="off" placeholder="停用日期" />
        </a-form-model-item>
        <a-form-model-item label="是否控制信用额度" prop="bCredit">
          <a-input v-model="entity.bCredit" autocomplete="off" placeholder="是否控制信用额度" />
        </a-form-model-item>
        <a-form-model-item label="是否控制信用期限" prop="bCreditDate">
          <a-input v-model="entity.bCreditDate" autocomplete="off" placeholder="是否控制信用期限" />
        </a-form-model-item>
        <a-form-model-item label="客户级别" prop="CustomerKCode">
          <a-input v-model="entity.CustomerKCode" autocomplete="off" placeholder="客户级别" />
        </a-form-model-item>
        <a-form-model-item label="税率%" prop="iCusTaxRate">
          <a-input v-model="entity.iCusTaxRate" autocomplete="off" placeholder="税率%" />
        </a-form-model-item>
        <a-form-model-item label="分配给用户的时间" prop="allot_user_time">
          <a-input v-model="entity.allot_user_time" autocomplete="off" placeholder="分配给用户的时间" />
        </a-form-model-item>
        <a-form-model-item label="省份" prop="cProvince">
          <a-input v-model="entity.cProvince" autocomplete="off" placeholder="省份" />
        </a-form-model-item>
        <a-form-model-item label="城市" prop="cCity">
          <a-input v-model="entity.cCity" autocomplete="off" placeholder="城市" />
        </a-form-model-item>
        <a-form-model-item label="区县" prop="cCounty">
          <a-input v-model="entity.cCounty" autocomplete="off" placeholder="区县" />
        </a-form-model-item>
        <a-form-model-item label="地区;街道" prop="District">
          <a-input v-model="entity.District" autocomplete="off" placeholder="地区;街道" />
        </a-form-model-item>
        <a-form-model-item label="上级组织;父级ID" prop="ParentId">
          <a-input v-model="entity.ParentId" autocomplete="off" placeholder="上级组织;父级ID" />
        </a-form-model-item>
        <a-form-model-item label="分配状态 0 未分配 1 已分配" prop="AllocationStatus">
          <a-input v-model="entity.AllocationStatus" autocomplete="off" placeholder="分配状态 0 未分配 1 已分配" />
        </a-form-model-item>
        <a-form-model-item label="来源备注" prop="OriginRemark">
          <a-input v-model="entity.OriginRemark" autocomplete="off" placeholder="来源备注" />
        </a-form-model-item>
        <a-form-model-item label="其他备注" prop="Remark">
          <a-input v-model="entity.Remark" autocomplete="off" placeholder="其他备注" />
        </a-form-model-item>
        <a-form-model-item label="客户类型;0 潜在  1 正式   2 休眠" prop="cCusType">
          <a-input v-model="entity.cCusType" autocomplete="off" placeholder="客户类型;0 潜在  1 正式   2 休眠" />
        </a-form-model-item>
        <a-form-model-item label="开票要求" prop="IRInfo">
          <a-input v-model="entity.IRInfo" autocomplete="off" placeholder="开票要求" />
        </a-form-model-item>
        <a-form-model-item label="销售性质;直销、渠道、代理" prop="SaleType">
          <a-input v-model="entity.SaleType" autocomplete="off" placeholder="销售性质;直销、渠道、代理" />
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  props: {
    parentObj: Object
  },
  data () {
    return {
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 18 }
      },
      visible: false,
      loading: false,
      entity: {},
      rules: {},
      title: ''
    }
  },
  methods: {
    init () {
      this.visible = true
      this.entity = {}
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
    },
    openForm (id, title) {
      this.init()
      this.title = title
      if (id) {
        this.loading = true
        this.$http.post('/CustomerManagement/CustomerInfo/GetTheData', { id: id }).then(resJson => {
          this.loading = false

          this.entity = resJson.Data
        })
      }
    },
    handleSubmit () {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loading = true
        this.$http.post('/CustomerManagement/CustomerInfo/SaveData', this.entity).then(resJson => {
          this.loading = false

          if (resJson.Success) {
            this.$message.success('操作成功!')
            this.visible = false

            this.parentObj.getDataList()
          } else {
            this.$message.error(resJson.Msg)
          }
        })
      })
    }
  }
}
</script>
